package com.jerry.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;

/**
 * Created by Shirly on 2016/12/5.
 */
public class test5 {
    public static void main(String[] args) {
        Map<String,Object> map = new HashMap<>();
        List list = new ArrayList<>();
        try {
            Class a = Class.forName("java.util.List");
           Method method =  a.getDeclaredMethod("add", Object.class);
            method.invoke(list,"A");
            System.out.println(list.get(0));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
